//
// Decompiled with: Decompiler.NET, Version=1.3.1.18439, Culture=neutral, PublicKeyToken=null, Version: 1.3.1.18439
// Decompilation Started at: 3/15/2009 10:34:26 PM
// Copyright 2003 - 2004, Jungle Creatures, Inc., All Rights Reserved. 
// Written by Jonathan Pierce, Email: support@junglecreatures.com
//

namespace PatientManagement

{
		
		#region Namespace Import Declarations
		
			using System.ComponentModel;
			using System.Data.Common;
			using System.Data;
			using System.Data.SqlClient;
			using System.Drawing;
			using System.Drawing.Printing;
			using System;
			using System.IO;
			using System.Resources;
			using System.Windows.Forms;
			using Utility;
			
		#endregion
		
	public class frmLapHinhAnh : Form
	
	{
		
		#region Fields
			private frmHoSoBenhAn _fHoSoBenhAn;
			private Button btBrowse;
			private Button btPrint;
			private Button btSave;
			private Button btThoat;
			private IContainer components;
			private string connStr;
			private Database_Com db;
			private string ext;
			public int flag;
			private Label label1;
			private Label lbPath;
			private Panel panel1;
			private string path;
			private PictureBox picPatients;
			private TextBox tbMoTa;
			private ToolTip toolTip1;
		#endregion
		
		#region Constructors
		
			public frmLapHinhAnh (frmHoSoBenhAn fHoSoBenhAn)
			
			{
				this.db = new Database_Com ();
				this.flag = 1;
				this._fHoSoBenhAn = fHoSoBenhAn;
				this.InitializeComponent ();
				this.connStr = Connection.ConnectionString ();
				return;
			}
			
		#endregion
		
		#region Methods
		
			private void btBrowse_Click (object sender, EventArgs e)
			
			{
				OpenFileDialog theOpenFileDialog;
				theOpenFileDialog = new OpenFileDialog ();
				theOpenFileDialog.Filter = "JPEG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif|Bitmap Files (*.bmp)|*.bmp";
				theOpenFileDialog.FilterIndex = 1;
				theOpenFileDialog.RestoreDirectory = true;
				if (theOpenFileDialog.ShowDialog () != DialogResult.OK)
				{
					goto L_0097;
				}
				this.path = theOpenFileDialog.FileName.ToString ();
				this.ext = Path.GetExtension (this.path);
				this.lbPath.Text = this.path;
				this.picPatients.Image = Image.FromFile (this.path);
				this.picPatients.SizeMode = PictureBoxSizeMode.Normal;
				this.picPatients.ClientSize = new System.Drawing.Size (700, 550);
				
			L_0097:
				return;
			}
			
			private void btPrint_Click (object sender, EventArgs e)
			
			{
				PrintDocument thePrintDocument;
				if (this.picPatients.Image == null)
				{
					goto L_002D;
				}
				thePrintDocument = new PrintDocument ();
				thePrintDocument.PrintPage += new PrintPageEventHandler (this.pd_PrintPage);
				thePrintDocument.Print ();
				goto L_0040;
				
			L_002D:
				
				{
				}
				DialogResult theDialogResult = MessageBox.Show ("Vui l?ng ch?n ?nh", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				
			L_0040:
				return;
			}
			
			private void btSave_Click (object sender, EventArgs e)
			
			{
				string theString;
				SqlConnection theSqlConnection;
				SqlDataAdapter theSqlDataAdapter;
				DataSet theDataSet;
				DataTable theDataTable;
				string theString2;
				Exception theException;
				string[] theStringArray;
				SqlDbType[] theSqlDbTypeArray;
				object[] theObjectArray;
				theString = this._fHoSoBenhAn.clrISN.ToString ();
				if (this.tbMoTa.Text != "")
				{
					goto L_0040;
				}
				DialogResult theDialogResult = MessageBox.Show ("Vui l?ng nh?p m? t?", "L?i nh?p", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				goto L_01B2;
				
			L_0040:
				
				{
				}
				if (! File.Exists (this.path))
				{
					goto L_019F;
				}
				theSqlConnection = new SqlConnection (this.connStr);
				theSqlDataAdapter = new SqlDataAdapter ("Select IDENT_CURRENT(\'ClinicalPicture\')", theSqlConnection);
				theDataSet = new DataSet ();
				int i = theSqlDataAdapter.Fill (theDataSet, "ClinicalPicture");
				theDataTable = theDataSet.Tables["ClinicalPicture"];
				theString2 = string.Concat (Application.StartupPath, "\\PatientImages\\", Convert.ToString (((int) (int.Parse (theDataTable.Rows[0][0].ToString ()) + 1))), this.ext);
				theSqlDataAdapter.Dispose ();
				theSqlConnection.Close ();
				File.Copy (this.path, theString2, true);
				
			L_00E2:
				try
				{
					SqlConnection theSqlConnection2 = this.db.CreateConnections ();
					theStringArray = new string[3];
					theStringArray[0] = "@clrISN";
					theStringArray[1] = "@clpPrictureDescription";
					theStringArray[2] = "@clpPicture";
					theSqlDbTypeArray = new SqlDbType[3];
					theSqlDbTypeArray[0] = SqlDbType.Int;
					theSqlDbTypeArray[1] = SqlDbType.NVarChar;
					theSqlDbTypeArray[2] = SqlDbType.NVarChar;
					theObjectArray = new object[3];
					theObjectArray[0] = theString;
					theObjectArray[1] = this.tbMoTa.Text.ToString ();
					theObjectArray[2] = theString2;
					this.db.ExecuteStoredProc ("sp_ClinicalPicture_Insert", theStringArray, theSqlDbTypeArray, theObjectArray);
					DialogResult theDialogResult2 = MessageBox.Show ("?nh ?? ???c l?u", "Ch?n H?nh", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
					this.tbMoTa.Text = "";
				}
				catch (Exception theException2)
				{
					
				L_018C:
					theException = theException2;
					DialogResult theDialogResult3 = MessageBox.Show (theException.Message);
				}
				
			L_019D:
				
				{
				}
				goto L_01B2;
				
			L_019F:
				
				{
				}
				DialogResult theDialogResult4 = MessageBox.Show ("Vui l?ng ch?n ?nh!", "Ch?a ch?n ?nh", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				
			L_01B2:
				return;
			}
			
			private void btThoat_Click (object sender, EventArgs e)
			
			{
				base.Close ();
				return;
			}
			
			protected override void Dispose (bool disposing)
			
			{
				this.flag = 0;
				if (! disposing)
				{
					goto L_001D;
				}
				if (this.components == null)
				{
					goto L_001D;
				}
				this.components.Dispose ();
				
			L_001D:
				
				{
				}
				base.Dispose (disposing);
				return;
			}
			
			private void frmLapHinhAnh_Load (object sender, EventArgs e)
			
			{
				return;
			}
			
			private void InitializeComponent ()
			
			{
				ResourceManager theResourceManager;
				Control[] theControlArray;
				Control[] theControlArray2;
				this.components = ((IContainer) new System.ComponentModel.Container ());
				theResourceManager = new ResourceManager (typeof (frmLapHinhAnh));
				this.tbMoTa = new TextBox ();
				this.label1 = new Label ();
				this.btThoat = new Button ();
				this.btSave = new Button ();
				this.btBrowse = new Button ();
				this.lbPath = new Label ();
				this.panel1 = new Panel ();
				this.picPatients = new PictureBox ();
				this.toolTip1 = new ToolTip (this.components);
				this.btPrint = new Button ();
				this.panel1.SuspendLayout ();
				base.SuspendLayout ();
				this.tbMoTa.BorderStyle = BorderStyle.FixedSingle;
				this.tbMoTa.Location = new Point (70, 328);
				this.tbMoTa.Name = "tbMoTa";
				this.tbMoTa.Size = new System.Drawing.Size (248, 22);
				this.tbMoTa.TabIndex = 22;
				this.tbMoTa.Text = "";
				this.label1.Location = new Point (18, 328);
				this.label1.Name = "label1";
				this.label1.TabIndex = 21;
				this.label1.Text = "M? t?:";
				this.btThoat.FlatStyle = FlatStyle.Popup;
				this.btThoat.Location = new Point (238, 360);
				this.btThoat.Name = "btThoat";
				this.btThoat.Size = new System.Drawing.Size (80, 23);
				this.btThoat.TabIndex = 20;
				this.btThoat.Text = "Tho?t";
				this.btThoat.Click += new EventHandler (this.btThoat_Click);
				this.btSave.FlatStyle = FlatStyle.Popup;
				this.btSave.Location = new Point (154, 360);
				this.btSave.Name = "btSave";
				this.btSave.Size = new System.Drawing.Size (80, 23);
				this.btSave.TabIndex = 19;
				this.btSave.Text = "L?u";
				this.btSave.Click += new EventHandler (this.btSave_Click);
				this.btBrowse.FlatStyle = FlatStyle.Popup;
				this.btBrowse.Font = new System.Drawing.Font ("Verdana", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.btBrowse.Location = new Point (286, 296);
				this.btBrowse.Name = "btBrowse";
				this.btBrowse.Size = new System.Drawing.Size (32, 23);
				this.btBrowse.TabIndex = 18;
				this.btBrowse.Text = "...";
				this.toolTip1.SetToolTip (((Control) this.btBrowse), "Ch?n ?nh");
				this.btBrowse.Click += new EventHandler (this.btBrowse_Click);
				this.lbPath.BorderStyle = BorderStyle.Fixed3D;
				this.lbPath.Location = new Point (18, 296);
				this.lbPath.Name = "lbPath";
				this.lbPath.Size = new System.Drawing.Size (256, 23);
				this.lbPath.TabIndex = 17;
				this.panel1.BorderStyle = BorderStyle.FixedSingle;
				theControlArray = new Control[1];
				theControlArray[0] = ((Control) this.picPatients);
				this.panel1.Controls.AddRange (theControlArray);
				this.panel1.Location = new Point (18, 40);
				this.panel1.Name = "panel1";
				this.panel1.Size = new System.Drawing.Size (300, 250);
				this.panel1.TabIndex = 16;
				this.picPatients.Name = "picPatients";
				this.picPatients.Size = new System.Drawing.Size (300, 250);
				this.picPatients.TabIndex = 0;
				this.picPatients.TabStop = false;
				this.btPrint.FlatStyle = FlatStyle.Popup;
				this.btPrint.Image = ((Image) ((Bitmap) theResourceManager.GetObject ("btPrint.Image")));
				this.btPrint.Location = new Point (294, 8);
				this.btPrint.Name = "btPrint";
				this.btPrint.Size = new System.Drawing.Size (24, 24);
				this.btPrint.TabIndex = 28;
				this.toolTip1.SetToolTip (((Control) this.btPrint), "In ?nh");
				this.btPrint.Click += new EventHandler (this.btPrint_Click);
				this.AutoScaleBaseSize = new System.Drawing.Size (7, 15);
				base.ClientSize = new System.Drawing.Size (336, 395);
				theControlArray2 = new Control[8];
				theControlArray2[0] = ((Control) this.btPrint);
				theControlArray2[1] = ((Control) this.tbMoTa);
				theControlArray2[2] = ((Control) this.label1);
				theControlArray2[3] = ((Control) this.btThoat);
				theControlArray2[4] = ((Control) this.btSave);
				theControlArray2[5] = ((Control) this.btBrowse);
				theControlArray2[6] = ((Control) this.lbPath);
				theControlArray2[7] = ((Control) this.panel1);
				base.Controls.AddRange (theControlArray2);
				this.Font = new System.Drawing.Font ("Verdana", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
				base.Icon = ((System.Drawing.Icon) theResourceManager.GetObject ("$this.Icon"));
				base.MaximizeBox = false;
				base.MinimizeBox = false;
				base.Name = "frmLapHinhAnh";
				base.StartPosition = FormStartPosition.CenterScreen;
				this.Text = "H?nh ?nh";
				base.Load += new EventHandler (this.frmLapHinhAnh_Load);
				this.panel1.ResumeLayout (false);
				base.ResumeLayout (false);
				return;
			}
			
			private void pd_PrintPage (object sender, PrintPageEventArgs e)
			
			{
				e.Graphics.DrawImage (this.picPatients.Image, e.Graphics.VisibleClipBounds);
				e.HasMorePages = false;
				return;
			}
			
		#endregion
	}
	
}

